﻿using System;
using Besture.Bll;
using Besture.Model;

namespace Besture.UI.Admin.Control
{
    public partial class SelectArticleClass : System.Web.UI.UserControl
    {
        /// <summary>
        /// "顶级类别"标识
        /// </summary>
        public bool _NeedTopClass;
        /// <summary>
        /// 显示选择按钮
        /// </summary>
        public bool? ShowSelectButton { get; set; }
        /// <summary>
        /// 是否仅显示当前栏目
        /// </summary>
        public bool? ShowCurrentPart { get; set; }
        /// <summary>
        /// 当前栏目ID
        /// </summary>
        public string CurrentPartID { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            if(ShowSelectButton == null)
            {
                ShowSelectButton = true;
            }
            //默认显示所有栏目
            if(ShowCurrentPart == null)
            {
                ShowCurrentPart = false;
            }
        }


        /// <summary>
        /// 父栏目名称
        /// </summary>
        public string ParentName
        {

            get { return txtParentName.Text; }

        }

        /// <summary>
        /// 父栏目序号
        /// </summary>
        public int ParentId
        {
            get { return string.IsNullOrEmpty(txtParentId.Text) ? 0 : Convert.ToInt32(txtParentId.Text); }

            set
            {
                txtParentId.Text = value.ToString();

                if (value == 0)
                {
                    txtParentName.Text = "顶级栏目";
                }
                else
                {
                    PartDac dac = new PartDac();
                    PartModel model = dac.GetModel(value);
                    txtParentName.Text = model.Name;
                    _TypeID = model.TypeID.ToString();
                }
            }
        }

        /// <summary>
        /// 是否需要“顶级类别”
        /// </summary>
        public bool NeedTopClass
        {
            set { _NeedTopClass = value; }
        }

        public string _TypeID { get; set; }
    }
}